/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.uml_generator.model.impl;

/**
 * {@link com.genia.toolbox.uml_generator.model.DataTypeModel} for an existent
 * class.
 */
public class ExistentDataTypeModel
    extends DataTypeModelImpl
{

  /**
   * the class this model represents.
   */
  private Class<?> baseClass;

  /**
   * the prefix to the name of the class that is used for the implementation of
   * the base class.
   */
  private String implementationPrefixName;



  /**
   * constructor.
   */
  public ExistentDataTypeModel()
  {
    // For decoration.
  }



  /**
   * constructor.
   * 
   * @param umlId
   *          the umlId of the entity
   * @param baseClass
   *          the class this model represents
   * @param implementationPrefixName
   *          the prefix to the name of the class that is used for the
   *          implementation of the base class
   */
  public ExistentDataTypeModel(String umlId, Class<?> baseClass, String implementationPrefixName)
  {
    setUmlId(umlId);
    setBaseClass(baseClass);
    setImplementationPrefixName(implementationPrefixName);
    super.setPackageName(baseClass.getPackage() == null ? "" : getBaseClass().getPackage().getName());
    super.setName(getBaseClass().getSimpleName());
  }



  /**
   * constructor.
   * 
   * @param baseClass
   *          the class this model represents
   * @param implementationPrefixName
   *          the prefix to the name of the class that is used for the
   *          implementation of the base class
   */
  public ExistentDataTypeModel(Class<?> baseClass, String implementationPrefixName)
  {
    this(baseClass.getName() + "ExistentDataTypeModel", baseClass, implementationPrefixName);
  }



  /**
   * returns the default value of the object.
   * 
   * @return the default value of the object
   */
  @Override
  public String getDefaultValue()
  {
    return "new " + getQualifiedName(getPackageName(), getImplementationPrefixName() + getName()) + "()";

  }



  /**
   * getter for the baseClass property.
   * 
   * @return the baseClass
   */
  public Class<?> getBaseClass()
  {
    return baseClass;
  }



  /**
   * setter for the baseClass property.
   * 
   * @param baseClass
   *          the baseClass to set
   */
  public void setBaseClass(Class<?> baseClass)
  {
    this.baseClass = baseClass;
  }



  /**
   * getter for the implementationPrefixName property.
   * 
   * @return the implementationPrefixName
   */
  public String getImplementationPrefixName()
  {
    return implementationPrefixName;
  }



  /**
   * setter for the implementationPrefixName property.
   * 
   * @param implementationPrefixName
   *          the implementationPrefixName to set
   */
  public void setImplementationPrefixName(String implementationPrefixName)
  {
    this.implementationPrefixName = (implementationPrefixName == null ? "" : implementationPrefixName);
  }

}
